/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.actions.modelo;

import com.mapping.Marca;
import com.mapping.Modelo;
import com.mapping.TipoDisp;
import com.opensymphony.xwork2.ActionSupport;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
/**
 *
 * @author PARDmx
 */
@Namespace(value = "/")
@Action(value = "consultaModeloP", results = {
@Result(name = "success", location = "/GestionModelos/resultadoConsultaModelo.jsp")})
public class ConsultasModeloAction extends ActionSupport{
    private Marca marca;
    private Modelo modelo;
    private TipoDisp tipo;
    private String idModelo;
    
    @Override
    public String execute(){           
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("inventarios");
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();                     
        modelo = (Modelo)em.getReference(Modelo.class, Integer.parseInt(idModelo));                         
        marca = modelo.getIdMarca();
        tipo = modelo.getIdTipo();
        em.flush();
        tx.commit();
        em.close();           
        return SUCCESS;
    }  

    public Marca getMarca() {
        return marca;
    }

    public Modelo getModelo() {
        return modelo;
    }

    public TipoDisp getTipo() {
        return tipo;
    }

    public void setIdModelo(String idModelo) {
        this.idModelo = idModelo;
    }
    
}
